# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/04 21:42
Author     : ZhangYafei
Description: 字符串
"""
""" 1. 字符串的定义 """
str1 = '人生只管努力，其他交给天意'
str2 = "人生只管努力，其他交给天意"
str3 = '''人生只管努力，其他交给天意'''
str4 = """人生只管努力，其他交给天意"""
str5 = '人生不得已，才当"主角"'
str6 = "人生不得已，才当'主角'"

""" 2. 字符串的独有功能 """
str7 = '孟子曰：爱人者，人恒爱之；敬人者，人恒敬之。'
print(str7.startswith('孟子曰'))
print(str7.endswith('。'))

str8 = '1'  # 数字字符串
print(str8.isdigit())  # True
print(str8.isdecimal())  # True
print(str8.isnumeric())  # True

str9 = b'1'
print(str9.isdigit())  # True
# print(str9.isdecimal())  # 报错
# print(str9.isnumeric())  # 报错

str10 = '四'  # 汉字数字
print(str10.isdigit())    # False
print(str10.isdecimal())  # False
print(str10.isnumeric())  # True

str11 = "Ⅳ"  # 罗马数字
print(str11.isdigit())    # False
print(str11.isdecimal())  # False
print(str11.isnumeric())  # True

str12 = " H e ll o啊，树哥 "
print(str12.strip())  # H e ll o啊，树哥
print(str12.lstrip())
print(str12.rstrip())

str13 = "哥H e ll o啊，树哥"
print(str13.strip('哥'))  # H e ll o啊，树

str14 = "my name is oliver queen"
print(str14.upper().lower())

str15 = "你是个好人，但是好人不合适我"
print(str15.replace('你', '我'))

str16 = "张亚飞|root|zhangyafei@qq.com"
print(str16.split('|', maxsplit=1))  # ['张亚飞', 'root', 'zhangyafei@qq.com']
print(str16.rsplit('|', maxsplit=1))  # ['张亚飞', 'root', 'zhangyafei@qq.com']

import os

for file in os.listdir('G:/学习/Python学习/Python基础/05_数据类型（上）'):
    if file.endswith('.py'):
        print(file.replace('py', 'PY'))

data_list = ["xiaoming","是","大烧饼"]
v1 = "*".join(data_list) # xiaoming_是_大烧饼
print(v1)


str17 = " H e ll o啊，树哥 "
print(str17.strip())   # 将两边的空白去掉，得到"H e ll o啊，树哥"
print(str17.lstrip())   # 将左边的空白去掉，得到"H e ll o啊，树哥 "
print(str17.rstrip())   # 将右边的空白去掉，得到" H e ll o啊，树哥"



str12 = 'Life is short, I use python'




